﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using System.Windows.Navigation;
using Croxweb.Leuphana.ViewModels;
using Croxweb.Leuphana.Models;
using Microsoft.Phone.Tasks;

namespace Croxweb.Leuphana.Pages
{
    public partial class MessagePage : PhoneApplicationPage
    {
        private MessageViewModel viewModel;

        public MessagePage()
        {
            InitializeComponent();
        }


        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            String id;
            NavigationContext.QueryString.TryGetValue("id", out id);

            Message message = App.MyStudyService.GetMessage(int.Parse(id));

            viewModel = new MessageViewModel(message);
            DataContext = viewModel;
        }

        private void Reply_Click(object sender, EventArgs e)
        {
            EmailComposeTask task = new EmailComposeTask();
            task.Subject = "Re: " + viewModel.Subject;
            task.To = viewModel.Sender.EmailAddress;

            task.Show();
        }
    }
}